/*
 *   Copyright 2021 zzh
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

package com.aduib.boot.logging.operation.handler;

import com.aduib.boot.logging.appender.LogAppender;
import com.aduib.boot.logging.operation.annotation.OpLog;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @description: OpLogHandler
 * @author: zzh
 * @date: 2021/9/17 10:32
 */
public interface OpLogHandler<T> extends LogAppender<T> {

  /**
   * 处理日志
   * @param opLog
   * @param joinpoint
   */
  default void handleLog(OpLog opLog, ProceedingJoinPoint joinpoint) {
    T t = buildLog(opLog, joinpoint);
    saveLog(t);
  }

  /**
   * 创建日志
   * @param opLog
   * @param joinpoint
   * @return
   */
  T buildLog(OpLog opLog, ProceedingJoinPoint joinpoint);

  /**
   * 保存日志
   * @param t
   */
  @Override
  void saveLog(T t);
}
